#include<stdio.h>
#include<time.h>
//2.2while循环和do-while循环
//3n+1问题
int main()
{
	int n2, count = 0;
	scanf_s("%d", &n2);
	long long n = n2;
	while (n > 1)
	{
		if (n % 2 == 1)  n = 3 * n + 1;
		else n /= 2;
		count++;
	}
	printf("%d\n", count);
	return 0;
}

//近似计算
int main()
{
	double sum = 0;
	for (int i = 0;;i++)
	{
		double term = 1.0 / (2 * i + 1);
		if (i % 2 == 0)  sum += term;
		else  sum -= term;
		if (term < 1e-6) break;   //1e-6表示10的-6次方
	}
	printf("%.6f", sum);
	return 0;
}


//2.3循环的代价
//阶乘之和
int main()
{
	int n, S = 0;
	scanf_s("%d", &n);
	for (int i = 1;i <= n;i++)
	{
		int factorial = 1;  //累乘器“阶乘”定义在循环里面。每执行一次循环体，都要重新声明一次factorial,并初始化为1
		for (int j = 1;j <= i;j++)
			factorial *= j;    //计算i!
		S += factorial;
	}
	printf("%d\n", S % 1000000); //因为只要末6位，所以输出时对1000000取模
	return 0;
}

//每步取模，加一个计时器
int main()
{
	const int MOD = 1000000;
	int n, S = 0;
	scanf_s("%d", &n);
	for (int i = 1;i <= n;i++)
	{
		int factorial = 1;
		for (int j = 1;j <= i;j++)
			factorial = (factorial * j % MOD);
		S = (S + factorial) % MOD;
	}
	printf("%d\n", S);
	printf("Time used=%.2f\n", (double)clock() / CLOCKS_PER_SEC);
	return 0;
}